﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CarHelpDesk.Web.Models.Question>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Нов въпрос
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm("Create", "Questions", FormMethod.Post, new { id = "question_form",  enctype = "multipart/form-data" }))
       {
    %>
        <%= Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Моля, опишете своя проблем</legend>        
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Title) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Title) %>
                <%= Html.ValidationMessageFor(model => model.Title) %>
            </div>            
                       
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Content) %>
            </div>
            <div class="editor-field">
                <%= Html.TextAreaFor(model => model.Content, 3, 50, null) %>
                <%= Html.ValidationMessageFor(model => model.Content) %>
            </div>
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Tags) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Tags)%>
            </div>             
            <div class="editor-label">
                Картинка
                            <input type='button' value='add' onclick="addFileUploadButton();" />
            </div>      
            <div class="files-editor-field">
                <input type="hidden" value="1" id="fileCnt"/>
                <input type="file" id="fileUp0" name="fileUp0"/>
            </div>       
            <p>
                <input type="submit" value="Изпрати" onclick="checkAuthentication(); return false;" />
            </p>
        </fieldset>

    <% } %>
    <script type="text/javascript">
        function addFileUploadButton() {
            var fileCnt = document.getElementById("fileCnt").value;            
            $("<br /><input type=\"file\" id=\"fileUp" + fileCnt + "\" name=\"fileUp" + fileCnt + "\" />").hide().appendTo(".files-editor-field").fadeIn("slow");
            fileCnt = (fileCnt - 1) + 2;
            document.getElementById("fileCnt").value = fileCnt;
        }

    function userAuthenticated() {
        $('#question_form').submit();
    }
    
    </script>
</asp:Content>

